﻿<template>
  <div>
    <a-card :bordered="false" :bodyStyle="tstyle">

      <div class="table-page-search-wrapper" v-if="hasPerm('Nitf6201InputFeedetail:page')">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="个人编码">
                <a-input v-model="queryParam.psnNo" allow-clear placeholder="请输入个人编码"/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="费用明细流水号单次就诊内唯一 ">
                <a-input v-model="queryParam.feedetlsn" allow-clear placeholder="请输入费用明细流水号单次就诊内唯一 "/>
              </a-form-item>
            </a-col><template v-if="advanced">
              <a-col :md="8" :sm="24">
                <a-form-item label="就诊ID ">
                  <a-input v-model="queryParam.mdtrtid" allow-clear placeholder="请输入就诊ID "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="人员编号 ">
                  <a-input v-model="queryParam.psnno" allow-clear placeholder="请输入人员编号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="收费批次号同一收费批次号病种编号必须一致 ">
                  <a-input v-model="queryParam.chrgbchno" allow-clear placeholder="请输入收费批次号同一收费批次号病种编号必须一致 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="病种编码按照标准编码填写：按病种结算病种目录代码(bydise_setl_lis t_code)、门诊慢特病病种目录代码(opsp_dise_cod) ">
                  <a-input v-model="queryParam.disecodg" allow-clear placeholder="请输入病种编码按照标准编码填写：按病种结算病种目录代码(bydise_setl_lis t_code)、门诊慢特病病种目录代码(opsp_dise_cod) "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="处方号外购处方时，传入外购处方的处方号；非外购处方，传入医药机构处方号 ">
                  <a-input v-model="queryParam.rxno" allow-clear placeholder="请输入处方号外购处方时，传入外购处方的处方号；非外购处方，传入医药机构处方号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="外购处方标志 ">
                  <a-input v-model="queryParam.rxcircflag" allow-clear placeholder="请输入外购处方标志 "/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="费用发生时间yyyy-MM-ddHH:mm:ss ">
                  <a-date-picker style="width: 100%" placeholder="请选择费用发生时间yyyy-MM-ddHH:mm:ss " v-model="queryParam.feeocurtimeDate" @change="onChangefeeocurtime"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医疗目录编码 ">
                  <a-input v-model="queryParam.medlistcodg" allow-clear placeholder="请输入医疗目录编码 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医药机构目录编码 ">
                  <a-input v-model="queryParam.medinslistcodg" allow-clear placeholder="请输入医药机构目录编码 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="明细项目费用总额 ">
                  <a-input v-model="queryParam.detitemfeesumamt" allow-clear placeholder="请输入明细项目费用总额 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="数量 ">
                  <a-input v-model="queryParam.cnt" allow-clear placeholder="请输入数量 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="单价 ">
                  <a-input v-model="queryParam.pric" allow-clear placeholder="请输入单价 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="单次剂量描述 ">
                  <a-input v-model="queryParam.sindosdscr" allow-clear placeholder="请输入单次剂量描述 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="使用频次描述 ">
                  <a-input v-model="queryParam.usedfrqudscr" allow-clear placeholder="请输入使用频次描述 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="周期天数 ">
                  <a-input v-model="queryParam.prddays" allow-clear placeholder="请输入周期天数 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="用药途径描述 ">
                  <a-input v-model="queryParam.medcwaydscr" allow-clear placeholder="请输入用药途径描述 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="开单科室编码 ">
                  <a-input v-model="queryParam.bilgdeptcodg" allow-clear placeholder="请输入开单科室编码 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="开单科室名称 ">
                  <a-input v-model="queryParam.bilgdeptname" allow-clear placeholder="请输入开单科室名称 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="开单医生编码按照标准编码填写 ">
                  <a-input v-model="queryParam.bilgdrcodg" allow-clear placeholder="请输入开单医生编码按照标准编码填写 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="开单医师姓名 ">
                  <a-input v-model="queryParam.bilgdrname" allow-clear placeholder="请输入开单医师姓名 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="受单科室编码 ">
                  <a-input v-model="queryParam.acorddeptcodg" allow-clear placeholder="请输入受单科室编码 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="受单科室名称 ">
                  <a-input v-model="queryParam.acorddeptname" allow-clear placeholder="请输入受单科室名称 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="受单医生编码按照标准编码填写 ">
                  <a-input v-model="queryParam.ordersdrcode" allow-clear placeholder="请输入受单医生编码按照标准编码填写 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="受单医生姓名 ">
                  <a-input v-model="queryParam.ordersdrname" allow-clear placeholder="请输入受单医生姓名 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医院审批标志 ">
                  <a-input v-model="queryParam.hospapprflag" allow-clear placeholder="请输入医院审批标志 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="中药使用方式 ">
                  <a-input v-model="queryParam.tcmdrugusedway" allow-clear placeholder="请输入中药使用方式 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="外检标志 ">
                  <a-input v-model="queryParam.etipflag" allow-clear placeholder="请输入外检标志 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="外检医院编码按照标准编码填写 ">
                  <a-input v-model="queryParam.etiphospcode" allow-clear placeholder="请输入外检医院编码按照标准编码填写 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="出院带药标志 ">
                  <a-input v-model="queryParam.dscgtkdrugflag" allow-clear placeholder="请输入出院带药标志 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="生育费用标志 ">
                  <a-input v-model="queryParam.matnfeeflag" allow-clear placeholder="请输入生育费用标志 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="原费用流水号退单时传入被退单的费用明细流水号 ">
                  <a-input v-model="queryParam.initfeedetlsn" allow-clear placeholder="请输入原费用流水号退单时传入被退单的费用明细流水号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医嘱号 ">
                  <a-input v-model="queryParam.drordno" allow-clear placeholder="请输入医嘱号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医疗类别 ">
                  <a-input v-model="queryParam.medtype" allow-clear placeholder="请输入医疗类别 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="备注 ">
                  <a-input v-model="queryParam.memo" allow-clear placeholder="请输入备注 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="扩展字段可参考FSI的接口要求 ">
                  <a-input v-model="queryParam.expcontent" allow-clear placeholder="请输入扩展字段可参考FSI的接口要求 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医疗目录名称 ">
                  <a-input v-model="queryParam.medlistname" allow-clear placeholder="请输入医疗目录名称 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="医疗目录规格 ">
                  <a-input v-model="queryParam.medlistspc" allow-clear placeholder="请输入医疗目录规格 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="组套编号可参考FSI的接口要求 ">
                  <a-input v-model="queryParam.combno" allow-clear placeholder="请输入组套编号可参考FSI的接口要求 "/>
                </a-form-item>
              </a-col>            </template>

            <a-col :md="8" :sm="24" >
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button>
                <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px"> {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>

          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card :bordered="false">
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :rowKey="(record) => record.iD"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
        <template class="table-operator" slot="operator" v-if="hasPerm('Nitf6201InputFeedetail:add')" >
          <a-button type="primary" v-if="hasPerm('Nitf6201InputFeedetail:add')" icon="plus" @click="$refs.addForm.add()">新增费用明细</a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a v-if="hasPerm('Nitf6201InputFeedetail:edit')" @click="$refs.editForm.edit(record)">编辑</a>
          <a-divider type="vertical" v-if="hasPerm('Nitf6201InputFeedetail:edit') & hasPerm('Nitf6201InputFeedetail:delete')"/>
          <a-popconfirm v-if="hasPerm('Nitf6201InputFeedetail:delete')" placement="topRight" title="确认删除？" @confirm="() => Nitf6201InputFeedetailDelete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
      <add-form ref="addForm" @ok="handleOk" />
      <edit-form ref="editForm" @ok="handleOk" />
    </a-card>
  </div>
</template>
<script>
  import { STable } from '@/components'
  import moment from 'moment'
  import { Nitf6201InputFeedetailPage, Nitf6201InputFeedetailDelete } from '@/api/modular/main/Nitf6201InputFeedetailManage'
  import addForm from './addForm.vue'
  import editForm from './editForm.vue'
  export default {
    components: {
      STable,
      addForm,
      editForm
    },
    data () {
      return {
        advanced: false, // 高级搜索 展开/关闭
        queryParam: {},
        columns: [
          {
            title: '个人编码',
            align: 'center',
            dataIndex: 'psnNo'
          },
          {
            title: '费用明细流水号单次就诊内唯一 ',
            align: 'center',
            dataIndex: 'feedetlsn'
          },
          {
            title: '就诊ID ',
            align: 'center',
            dataIndex: 'mdtrtid'
          },
          {
            title: '人员编号 ',
            align: 'center',
            dataIndex: 'psnno'
          },
          {
            title: '收费批次号同一收费批次号病种编号必须一致 ',
            align: 'center',
            dataIndex: 'chrgbchno'
          },
          {
            title: '病种编码按照标准编码填写：按病种结算病种目录代码(bydise_setl_lis t_code)、门诊慢特病病种目录代码(opsp_dise_cod) ',
            align: 'center',
            dataIndex: 'disecodg'
          },
          {
            title: '处方号外购处方时，传入外购处方的处方号；非外购处方，传入医药机构处方号 ',
            align: 'center',
            dataIndex: 'rxno'
          },
          {
            title: '外购处方标志 ',
            align: 'center',
            dataIndex: 'rxcircflag'
          },
          {
            title: '费用发生时间yyyy-MM-ddHH:mm:ss ',
            align: 'center',
            dataIndex: 'feeocurtime'
          },
          {
            title: '医疗目录编码 ',
            align: 'center',
            dataIndex: 'medlistcodg'
          },
          {
            title: '医药机构目录编码 ',
            align: 'center',
            dataIndex: 'medinslistcodg'
          },
          {
            title: '明细项目费用总额 ',
            align: 'center',
            dataIndex: 'detitemfeesumamt'
          },
          {
            title: '数量 ',
            align: 'center',
            dataIndex: 'cnt'
          },
          {
            title: '单价 ',
            align: 'center',
            dataIndex: 'pric'
          },
          {
            title: '单次剂量描述 ',
            align: 'center',
            dataIndex: 'sindosdscr'
          },
          {
            title: '使用频次描述 ',
            align: 'center',
            dataIndex: 'usedfrqudscr'
          },
          {
            title: '周期天数 ',
            align: 'center',
            dataIndex: 'prddays'
          },
          {
            title: '用药途径描述 ',
            align: 'center',
            dataIndex: 'medcwaydscr'
          },
          {
            title: '开单科室编码 ',
            align: 'center',
            dataIndex: 'bilgdeptcodg'
          },
          {
            title: '开单科室名称 ',
            align: 'center',
            dataIndex: 'bilgdeptname'
          },
          {
            title: '开单医生编码按照标准编码填写 ',
            align: 'center',
            dataIndex: 'bilgdrcodg'
          },
          {
            title: '开单医师姓名 ',
            align: 'center',
            dataIndex: 'bilgdrname'
          },
          {
            title: '受单科室编码 ',
            align: 'center',
            dataIndex: 'acorddeptcodg'
          },
          {
            title: '受单科室名称 ',
            align: 'center',
            dataIndex: 'acorddeptname'
          },
          {
            title: '受单医生编码按照标准编码填写 ',
            align: 'center',
            dataIndex: 'ordersdrcode'
          },
          {
            title: '受单医生姓名 ',
            align: 'center',
            dataIndex: 'ordersdrname'
          },
          {
            title: '医院审批标志 ',
            align: 'center',
            dataIndex: 'hospapprflag'
          },
          {
            title: '中药使用方式 ',
            align: 'center',
            dataIndex: 'tcmdrugusedway'
          },
          {
            title: '外检标志 ',
            align: 'center',
            dataIndex: 'etipflag'
          },
          {
            title: '外检医院编码按照标准编码填写 ',
            align: 'center',
            dataIndex: 'etiphospcode'
          },
          {
            title: '出院带药标志 ',
            align: 'center',
            dataIndex: 'dscgtkdrugflag'
          },
          {
            title: '生育费用标志 ',
            align: 'center',
            dataIndex: 'matnfeeflag'
          },
          {
            title: '原费用流水号退单时传入被退单的费用明细流水号 ',
            align: 'center',
            dataIndex: 'initfeedetlsn'
          },
          {
            title: '医嘱号 ',
            align: 'center',
            dataIndex: 'drordno'
          },
          {
            title: '医疗类别 ',
            align: 'center',
            dataIndex: 'medtype'
          },
          {
            title: '备注 ',
            align: 'center',
            dataIndex: 'memo'
          },
          {
            title: '扩展字段可参考FSI的接口要求 ',
            align: 'center',
            dataIndex: 'expcontent'
          },
          {
            title: '医疗目录名称 ',
            align: 'center',
            dataIndex: 'medlistname'
          },
          {
            title: '医疗目录规格 ',
            align: 'center',
            dataIndex: 'medlistspc'
          },
          {
            title: '组套编号可参考FSI的接口要求 ',
            align: 'center',
            dataIndex: 'combno'
          }
        ],
        tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return Nitf6201InputFeedetailPage(Object.assign(parameter, this.switchingDate())).then((res) => {
            return res.data
          })
        },
        selectedRowKeys: [],
        selectedRows: []
      }
    },
    created () {
      if (this.hasPerm('Nitf6201InputFeedetail:edit') || this.hasPerm('Nitf6201InputFeedetail:delete')) {
        this.columns.push({
          title: '操作',
          width: '150px',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        })
      }
    },
    methods: {
      moment,
      /**
       * 查询参数组装
       */
      switchingDate () {
        const queryParamfeeocurtime = this.queryParam.feeocurtimeDate
        if (queryParamfeeocurtime != null) {
            this.queryParam.feeocurtime = moment(queryParamfeeocurtime).format('YYYY-MM-DD')
            if (queryParamfeeocurtime.length < 1) {
                delete this.queryParam.feeocurtime
            }
        }
        const obj = JSON.parse(JSON.stringify(this.queryParam))
        return obj
      },
      Nitf6201InputFeedetailDelete (record) {
        Nitf6201InputFeedetailDelete(record).then((res) => {
          if (res.success) {
            this.$message.success('删除成功')
            this.$refs.table.refresh()
          } else {
            this.$message.error('删除失败') // + res.message
          }
        })
      },
      toggleAdvanced () {
        this.advanced = !this.advanced
      },
      onChangefeeocurtime(date, dateString) {
        this.feeocurtimeDateString = dateString
      },
      handleOk () {
        this.$refs.table.refresh()
      },
      onSelectChange (selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
      }
    }
  }
</script>
<style lang="less">
  .table-operator {
    margin-bottom: 18px;
  }
  button {
    margin-right: 8px;
  }
</style>
